<!DOCTYPE html>
<html xmlns:layout="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
	layout:decorate="~{common/layoutAdmin}">

<head>
	<meta charset="UTF-8">
	<title>咨询记录</title>
</head>

<body>
	<div layout:fragment="fragment_body">
		<el-row :gutter="20">
			<el-col :span="24">
				<!--<el-button type="primary" @click="openGuidanceInfo(null)">添 加</el-button>-->
				<el-table :data="guidanceInfos" border highlight-current-row style="width: 100%">
					<!-- -->
					<el-table-column prop="guidanceSendId" label="咨询人">
						<template slot-scope="scope">
						{{scope.row.send.accountNick}}
						</template>
					</el-table-column>
					<el-table-column prop="guidanceReceiveId" label="被咨询人">
						<template slot-scope="scope">
						{{scope.row.receive.accountNick}}
						</template>
					</el-table-column>
					<el-table-column prop="guidanceText" label="咨询内容"></el-table-column>
					<el-table-column prop="guidanceReply" label="咨询回复"></el-table-column>
					<el-table-column prop="guidanceTime" label="咨询时间"></el-table-column>
					<el-table-column prop="guidanceReplyTime" label="回复时间"></el-table-column>
					<!--<el-table-column label="操作" width="160px">
						<template slot-scope="scope">
							<el-button @click="openGuidanceInfo(scope.row)" type="text" size="small">修 改</el-button>
							<el-popconfirm title="是否删除？" @confirm="delGuidanceInfo(scope.row.guidanceId)">
								<el-button slot="reference" type="text" size="small">删 除</el-button>
							</el-popconfirm>
						</template>
					</el-table-column>-->
				</el-table>
			</el-col>
		</el-row>
		<!--弹框-->
		<el-dialog :title="guidanceInfoForm.ttitle" :visible.sync="guidanceInfoForm.visible" width="30%">
			<el-form :model="guidanceInfoForm" :rules="guidanceInfoRules" ref="guidanceInfoForm" label-width="100px">
				<!-- -->
				<el-form-item label="咨询人" prop="guidanceSendId">
					<el-input v-model="guidanceInfoForm.guidanceSendId"></el-input>
				</el-form-item>
				<el-form-item label="被咨询人" prop="guidanceReceiveId">
					<el-input v-model="guidanceInfoForm.guidanceReceiveId"></el-input>
				</el-form-item>
				<el-form-item label="咨询内容" prop="guidanceText">
					<el-input v-model="guidanceInfoForm.guidanceText"></el-input>
				</el-form-item>
				<el-form-item label="咨询回复" prop="guidanceReply">
					<el-input v-model="guidanceInfoForm.guidanceReply"></el-input>
				</el-form-item>
				<el-form-item label="咨询时间" prop="guidanceTime">
					<el-input v-model="guidanceInfoForm.guidanceTime"></el-input>
				</el-form-item>
				<el-form-item label="回复时间" prop="guidanceReplyTime">
					<el-input v-model="guidanceInfoForm.guidanceReplyTime"></el-input>
				</el-form-item>
			</el-form>
			<span slot="footer" class="dialog-footer">
				<el-button @click="closeGuidanceInfo">取 消</el-button>
				<el-button type="primary" @click="saveGuidanceInfo">保 存</el-button>
			</span>
		</el-dialog>
	</div>
</body>
<script type="text/javascript" layout:fragment="fragment_script">
	let vueData = {
		guidanceInfos: [],
		selectGuidanceInfo: null,
		guidanceInfoForm: {
			visible: false,
			ttitle: '新增/修改',
			guidanceId : '',
			guidanceSendId : '',
			guidanceReceiveId : '',
			guidanceText : '',
			guidanceReply : '',
			guidanceTime : '',
			guidanceReplyTime : '',
		},
		guidanceInfoQuery: {
			page: '',
			size: '',
		},
		guidanceInfoRules: {
			guidanceId: [
				{required: true, message: '不能为空', trigger: 'blur'}
			],
			guidanceSendId: [
				{required: true, message: '不能为空', trigger: 'blur'}
			],
			guidanceReceiveId: [
				{required: true, message: '不能为空', trigger: 'blur'}
			],
			guidanceText: [
				{required: true, message: '不能为空', trigger: 'blur'}
			],
			guidanceReply: [
				{required: true, message: '不能为空', trigger: 'blur'}
			],
			guidanceTime: [
				{required: true, message: '不能为空', trigger: 'blur'}
			],
			guidanceReplyTime: [
				{required: true, message: '不能为空', trigger: 'blur'}
			],
		},
	}
	let vueMethods = {
		getGuidanceInfos() {
			let that = this
			postRequst('/admin/getGuidances', that.guidanceInfoQuery, true).then(function (resp) {
				that.guidanceInfos = resp.rows
				if (resp.rows && resp.rows.length > 0) {
					that.selectGuidanceInfo = resp.rows[0]
				}
			})
		},
		openGuidanceInfo(row) {
			let that = this
			if (row) {
				that.guidanceInfoForm.ttitle = '修改'
				that.guidanceInfoForm.guidanceId = row.guidanceId
				that.guidanceInfoForm.guidanceSendId = row.guidanceSendId
				that.guidanceInfoForm.guidanceReceiveId = row.guidanceReceiveId
				that.guidanceInfoForm.guidanceText = row.guidanceText
				that.guidanceInfoForm.guidanceReply = row.guidanceReply
				that.guidanceInfoForm.guidanceTime = row.guidanceTime
				that.guidanceInfoForm.guidanceReplyTime = row.guidanceReplyTime
			} else {
				that.guidanceInfoForm.ttitle = '新增'
				that.guidanceInfoForm.guidanceId = ''
				that.guidanceInfoForm.guidanceSendId = ''
				that.guidanceInfoForm.guidanceReceiveId = ''
				that.guidanceInfoForm.guidanceText = ''
				that.guidanceInfoForm.guidanceReply = ''
				that.guidanceInfoForm.guidanceTime = ''
				that.guidanceInfoForm.guidanceReplyTime = ''
			}
			that.guidanceInfoForm.visible = true
		},
		closeGuidanceInfo() {
			this.$refs["guidanceInfoForm"].resetFields();
			this.guidanceInfoForm.visible = false
		},
		saveGuidanceInfo() {
			let that = this
			this.$refs["guidanceInfoForm"].validate((valid) => {
				if (valid) {
					postRequst('/admin/saveGuidanceInfo', that.guidanceInfoForm).then(function (resp) {
						if (resp.status == 0) {
							that.getGuidanceInfos()
							that.guidanceInfoForm.visible = false
							that.$message({message: resp.msg, type: "success"});
						} else {
							that.$message({message: resp.msg, type: "error"});
						}
					})
				}
			});
		},
		delGuidanceInfo(guidanceId) {
			let that = this
			postRequst('/admin/delGuidanceInfo', {guidanceId: guidanceId}, true).then(function (resp) {
				if (resp.status == 0) {
					that.getGuidanceInfos()
					that.$message({message: resp.msg, type: "success"});
				} else {
					that.$message({message: resp.msg, type: "error"});
				}
			})
		},
	}
	function vueCreated() {
		let that = this
		that.getGuidanceInfos()
	}
</script>

</html>